<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>档案管理系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/dist/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/static/dist/css/AdminLTE.min.css">
    <link rel="stylesheet" href="/static/dist/css/skins/all-skins.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-treeview.css">
    <link rel="stylesheet" href="/static/css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="/static/layer/theme/default/layer.css">
    <link rel="stylesheet" href="/static/css/viewer.min.css">
    <link rel="stylesheet" href="/static/webCss/jysq.css?v=shujubuwqd12138">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/static/plugins/ie9/html5shiv.min.js"></script>
    <script src="/static/plugins/ie9/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition skin-blue" style="font-size: medium">


<div class="content " id="yhgl">
    <div class="row">
        <div class="col-xs-3 left">
            <div class="row" style="height: 54px;border-bottom: 1px solid #E0E0E0">
                <label class="col-xs-4" style="color: #3A3A3A;font-weight: 600;padding-top: 17px;font-size: 16px">档案材料</label>
                <div class="btn-group col-xs-offset-3" style="padding-top: 17px;">
                    <a class="btn btn-primary" style="background-color: #2C75E8;width: 64px;height: 25px;border-radius:2px 0px 0px 2px;padding: 2px;" @click="selectAll">全选</a>
                    <a class="btn btn-default" style="width: 64px;height: 25px;color: #888888;border-radius:2px;padding: 2px;" @click="selectNull">反选</a>
                </div>
            </div>
            <div style="height: 700px;overflow: auto">
                <div id="tree"></div>
            </div>
        </div>
        <div class="col-xs-9 right">
            <div class="row" style="height: 54px;border-bottom: 1px solid #E0E0E0">
                <label class="col-xs-4" style="color: #3A3A3A;font-weight: 600;padding-top: 17px;font-size: 16px">借阅申请</label>
                <div class="btn-group col-xs-offset-6" style="padding-top: 17px;">
                    <a class="btn btn-primary" style="background-color: #2C75E8;width: 118px;height: 25px;border-radius:2px 0px 0px 2px;padding: 2px;margin-left: 60px;" @click="goback">返回</a>
                </div>
            </div>
            <div v-show="da">
                <form role="form" id="userForm">
                    <div class="form-inline col-xs-offset-3" style="margin-bottom: 20px;margin-top: 20px">
                        <label>档案编号:</label>
                        <label name="dabh" class="" style="width: 300px;">{{jyxx2.dabh}}</label>
                    </div>
                    <div class="form-inline col-xs-offset-3" style="margin-bottom: 20px">
                        <label>案卷题名:</label>
                        <label class="" name="damc" style="width: 300px;">{{jyxx2.damc}}</label>
                    </div>
                    <div class="form-inline col-xs-offset-3" style="margin-bottom: 20px">
                        <label>大厅受理编号:</label>
                        <label class="" name="dtslbh" style="width: 300px;">{{jyxx2.dtslbh}}</label>
                    </div>
                    <div class="form-inline col-xs-offset-3" style="margin-bottom: 20px">
                        <label>借阅原因:</label>
                        <textarea name="jyyy" v-model="jyxx2.jyyy" class="form-control" style="width: 300px;"></textarea>
                    </div>
                    <div class="form-inline col-xs-offset-3" style="margin-bottom: 20px">
                        <label>借阅人:&nbsp&nbsp&nbsp</label>
                        <input name="jyr" class="form-control" type="text" readonly v-model="jyxx2.jyr" style="width: 300px;">
                    </div>
                    <div class="form-inline col-xs-offset-3" style="margin-bottom: 20px">
                        <label>审核人:&nbsp&nbsp&nbsp</label>
                        <select name="shr" class="form-control" v-model="jyxx2.shrId" @change="shrChange" style="width: 300px;">
                            <option v-for="(v,k) in allShy" :value="v.id">{{v.name}}</option>
                        </select>
                    </div>
                    <div class="form-inline col-xs-offset-3" style="margin-bottom: 20px">
                        <label>借阅时限:</label>
                        <select name="jysx" class="form-control" v-model="jyxx2.jysx" style="width: 100px;">
                            <option value="5">五天</option>
                            <option value="10">十天</option>
                            <option value="15">十五天</option>
                            <option value="20">二十天</option>
                            <option value="30">三十天</option>
                        </select>
                    </div>
                    <div class=" text-center" style="padding: 40px">
                        <!--<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>-->
                        <button type="button" class="btn btn-primary" @click="doSq" style="width: 94px;height: 36px;background-color: #2C72E8">提交申请</button>
                        <!--<button type="button" class="btn btn-default" @click="cancel" style="width: 94px;height: 36px">取消</button>-->
                    </div>
                </form>
            </div>
        </div>

    </div>
</div>

<script src="/static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<!-- Slimscroll -->
<script src="/static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/static/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="/static/dist/js/app.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/static/dist/js/demo.js"></script>
<!--tabs-->
<script src="/static/dist/js/app_iframe.js"></script>
<script src="/static/js/bootstrap-treeview.js"></script>
<script src="/static/js/bootstrapValidator.min.js"></script>
<script src="/static/js/bootstrap-table.min.js"></script>
<script src="/static/js/bootstrap-table-zh-CN.js"></script>
<script src="/static/js/vue.js"></script>
<script src="/static/js/vue-resource.min.js"></script>
<script src="/static/layer/layer.js"></script>
<script src="/static/js/myJs.js?v=shujubuwqd12138"></script>
<script src="/static/js/viewer.min.js"></script>
<script src="/static/js/newJs.js?v=shujubuwqd12138"></script>

<script type="text/javascript">
    newCss("/static/webCss/jysq.css");
    var arr = new Array();
    var arr2 = new Array();
    var id;
    var viewer2;
    //键盘按下
    var kdLxNodes;
    var kdid;
    var kdId;
    var kdtreeNum;
    function paramsMatter(value,row,index) {
        var span=document.createElement('span');
        span.setAttribute('title',value);
        span.innerHTML = value;
        return span.outerHTML;
    }
    var nextid;
    var preid;
    var Id;
    var ids = new Array();
    //记录节点id；
    var nodeId;
    var nodeId2;
    //记录节点的个数
    var index;
    var nodeCheckedSilent = false;

    function nodeChecked(event, node) {
        if (nodeCheckedSilent) {
            return;
        }
        nodeCheckedSilent = true;
        checkAllParent(node);
        checkAllSon(node);
        nodeCheckedSilent = false;
    }

    var nodeUncheckedSilent = false;

    function nodeUnchecked(event, node) {
        if (nodeUncheckedSilent)
            return;
        nodeUncheckedSilent = true;
        uncheckAllParent(node);
        uncheckAllSon(node);
        nodeUncheckedSilent = false;
    }

    //选中全部父节点
    function checkAllParent(node) {
        $('#tree').treeview('checkNode', node.nodeId, {
            silent: true
        });
        var parentNode = $('#tree').treeview('getParent', node.nodeId);
        if (!("nodeId" in parentNode)) {
            return;
        } else {
            checkAllParent(parentNode);
        }
    }
    //取消全部父节点
    function uncheckAllParent(node) {
        $('#tree').treeview('uncheckNode', node.nodeId, {
            silent: true
        });
        var siblings = $('#tree').treeview('getSiblings', node.nodeId);
        var parentNode = $('#tree').treeview('getParent', node.nodeId);
        if (!("nodeId" in parentNode)) {
            return;
        }
        var isAllUnchecked = true; //是否全部没选中
        for (var i in siblings) {
            if (siblings[i].state.checked) {
                isAllUnchecked = false;
                break;
            }
        }
        if (isAllUnchecked) {
            uncheckAllParent(parentNode);
        }

    }

    //级联选中所有子节点
    function checkAllSon(node) {
        $('#tree').treeview('checkNode', node.nodeId, {
            silent: true
        });
        if (node.nodes != null && node.nodes.length > 0) {
            for (var i in node.nodes) {
                checkAllSon(node.nodes[i]);
            }
        }
    }
    //级联取消所有子节点
    function uncheckAllSon(node) {
        $('#tree').treeview('uncheckNode', node.nodeId, {
            silent: true
        });
        if (node.nodes != null && node.nodes.length > 0) {
            for (var i in node.nodes) {
                uncheckAllSon(node.nodes[i]);
            }
        }
    }

    var nodeCheckedSilent2 = false;

    function nodeChecked2(event, node) {
        if (nodeCheckedSilent2) {
            return;
        }
        nodeCheckedSilent2 = true;
        checkAllParent2(node);
        checkAllSon2(node);
        nodeCheckedSilent2 = false;
    }

    var nodeUncheckedSilent2 = false;

    function nodeUnchecked2(event, node) {
        if (nodeUncheckedSilent2)
            return;
        nodeUncheckedSilent2 = true;
        uncheckAllParent2(node);
        uncheckAllSon2(node);
        nodeUncheckedSilent2 = false;
    }

    //选中全部父节点
    function checkAllParent2(node) {
        $('#tree5').treeview('checkNode', node.nodeId, {
            silent: true
        });
        var parentNode = $('#tree5').treeview('getParent', node.nodeId);
        if (!("nodeId" in parentNode)) {
            return;
        } else {
            checkAllParent2(parentNode);
        }
    }
    //取消全部父节点
    function uncheckAllParent2(node) {
        $('#tree5').treeview('uncheckNode', node.nodeId, {
            silent: true
        });
        var siblings = $('#tree5').treeview('getSiblings', node.nodeId);
        var parentNode = $('#tree5').treeview('getParent', node.nodeId);
        if (!("nodeId" in parentNode)) {
            return;
        }
        var isAllUnchecked2 = true; //是否全部没选中
        for (var i in siblings) {
            if (siblings[i].state.checked) {
                isAllUnchecked2 = false;
                break;
            }
        }
        if (isAllUnchecked2) {
            uncheckAllParent2(parentNode);
        }

    }

    //级联选中所有子节点
    function checkAllSon2(node) {
        $('#tree5').treeview('checkNode', node.nodeId, {
            silent: true
        });
        if (node.nodes != null && node.nodes.length > 0) {
            for (var i in node.nodes) {
                checkAllSon2(node.nodes[i]);
            }
        }
    }
    //级联取消所有子节点
    function uncheckAllSon2(node) {
        $('#tree5').treeview('uncheckNode', node.nodeId, {
            silent: true
        });
        if (node.nodes != null && node.nodes.length > 0) {
            for (var i in node.nodes) {
                uncheckAllSon2(node.nodes[i]);
            }
        }
    }
    //打开上一张图片
    /*
    nowId为选择的节点id,
    ids为图片数组
    Id为借阅id
    treeNum分辨哪个treeview
     */
    function openpre(lxNodes,id,Id,treeNum) {
        preid = id;
        var upanddownImgVo = {
            'id':id,
            'type':0,
            'lxNodes':lxNodes,
        };
        $.ajax({
            url: '/jy/api/upanddownImg',
            type: 'post',
            dataType:'JSON',
            data: JSON.stringify(upanddownImgVo),
            cache: false,
            contentType: 'application/json; charset=UTF-8',
            processData: false,
            //dataType: "json",
            async: false,
            success: function (result) {
                if(result.code == 200){
                    var id = result.data;
                    preid = id;
                    kdid = id;
                    if(treeNum == 3){
                        $('#tree3Img').attr('dataUrl', '/jy/api/getImg?path='+id+'&jyId='+Id);
                        var viewer = new Viewer(document.getElementById('tree3'), {
                            inline: true,
                            url: 'dataUrl',
                            //navbar: false,
                            zIndexInline: 9999,
                            button: true,
                            backdrop: true,
                            keyboard:true,
                            navbar:false,
                            toolbar: {
                                zoomIn: {
                                    show: 1,
                                    click: function () {
                                        viewer.destroy();
                                    }
                                },
                                zoomOut: 0,
                                oneToOne: 0,
                                reset: 0,
                                prev: {
                                    show:1,
                                    click:function(){
                                        viewer.destroy();
                                        openpre(lxNodes,id,Id,3);
                                    }

                                },
                                next: {
                                    show:1,
                                    click:function(){
                                        viewer.destroy();
                                        opennext(lxNodes,id,Id,3)
                                    }
                                },
                                rotateLeft: 1,
                                rotateRight: 1,
                                flipHorizontal: 0,
                                flipVertical: 0,
                            },
                        });
                    }else if(treeNum == 2){
                        $('#tree2Img').attr('dataUrl', '/jy/api/getImg?path='+id+'&jyId='+Id);
                        viewer2 = new Viewer(document.getElementById('tree2'), {
                            inline: true,
                            url: 'dataUrl',
                            //navbar: false,
                            zIndexInline: 9999,
                            button: true,
                            backdrop: true,
                            keyboard:true,
                            navbar:false,
                            toolbar: {
                                zoomIn: {
                                    show: 1,
                                    click: function () {
                                        viewer2.destroy();
                                    }
                                },
                                zoomOut: 0,
                                oneToOne: 0,
                                reset: 0,
                                prev: {
                                    click:function(){
                                        viewer2.destroy();
                                        openpre(lxNodes,id,Id,2);
                                    }
                                },
                                next: {
                                    show:1,
                                    click:function(){
                                        viewer2.destroy();
                                        opennext(lxNodes,id,Id,2)
                                    }
                                },
                                rotateLeft: 1,
                                rotateRight: 1,
                                flipHorizontal: 0,
                                flipVertical: 0,
                            },
                        });
                    }
                }else {
                    cxAlertts("已经是第一张");
                    if(treeNum == 3){
                        $('#tree3Img').attr('dataUrl', '/jy/api/getImg?path='+preid+'&jyId='+Id);
                        var viewer = new Viewer(document.getElementById('tree3'), {
                            inline: true,
                            url: 'dataUrl',
                            //navbar: false,
                            zIndexInline: 9999,
                            button: true,
                            backdrop: true,
                            keyboard:true,
                            navbar:false,
                            toolbar: {
                                zoomIn: {
                                    show: 1,
                                    click: function () {
                                        viewer.destroy();
                                    }
                                },
                                zoomOut: 0,
                                oneToOne: 0,
                                reset: 0,
                                prev: {
                                    show:1,
                                    click:function(){
                                        viewer.destroy();
                                        openpre(lxNodes,preid,Id,3);
                                    }

                                },
                                next: {
                                    show:1,
                                    click:function(){
                                        viewer.destroy();
                                        opennext(lxNodes,preid,Id,3)
                                    }
                                },
                                rotateLeft: 1,
                                rotateRight: 1,
                                flipHorizontal: 0,
                                flipVertical: 0,
                            },
                        });
                    }else if(treeNum == 2){
                        $('#tree2Img').attr('dataUrl', '/jy/api/getImg?path='+preid+'&jyId='+Id);
                        viewer2 = new Viewer(document.getElementById('tree2'), {
                            inline: true,
                            url: 'dataUrl',
                            //navbar: false,
                            zIndexInline: 9999,
                            button: true,
                            backdrop: true,
                            keyboard:true,
                            navbar:false,
                            toolbar: {
                                zoomIn: {
                                    show: 1,
                                    click: function () {
                                        viewer2.destroy();
                                    }
                                },
                                zoomOut: 0,
                                oneToOne: 0,
                                reset: 0,
                                prev: {
                                    click:function(){
                                        viewer2.destroy();
                                        openpre(lxNodes,preid,Id,2);
                                    }
                                },
                                next: {
                                    show:1,
                                    click:function(){
                                        viewer2.destroy();
                                        opennext(lxNodes,preid,Id,2)
                                    }
                                },
                                rotateLeft: 1,
                                rotateRight: 1,
                                flipHorizontal: 0,
                                flipVertical: 0,
                            },
                        });
                    }
                }
            }
        });
    }
    //打开下一张
    function opennext(lxNodes,id,Id,treeNum) {
        nextid = id;
        var upanddownImgVo = {
            'id':id,
            'type':1,
            'lxNodes':lxNodes,
        };
        $.ajax({
            url: '/jy/api/upanddownImg',
            type: 'post',
            dataType:'JSON',
            data: JSON.stringify(upanddownImgVo),
            cache: false,
            contentType: 'application/json; charset=UTF-8',
            processData: false,
            //dataType: "json",
            async: false,
            success: function (result) {
                if(result.code == 200){
                    var id = result.data;
                    nextid = id;
                    kdid = id;
                    if(treeNum == 3){
                        $('#tree3Img').attr('dataUrl', '/jy/api/getImg?path='+id+'&jyId='+Id);
                        var viewer = new Viewer(document.getElementById('tree3'), {
                            inline: true,
                            url: 'dataUrl',
                            //navbar: false,
                            zIndexInline: 9999,
                            button: true,
                            backdrop: true,
                            keyboard:true,
                            navbar:false,
                            toolbar: {
                                zoomIn: {
                                    show: 1,
                                    click: function () {
                                        viewer.destroy();
                                    }
                                },
                                zoomOut: 0,
                                oneToOne: 0,
                                reset: 0,
                                prev: {
                                    show:1,
                                    click:function(){
                                        viewer.destroy();
                                        openpre(lxNodes,id,Id,3);
                                    }

                                },
                                next: {
                                    show:1,
                                    click:function(){
                                        viewer.destroy();
                                        opennext(lxNodes,id,Id,3)
                                    }
                                },
                                rotateLeft: 1,
                                rotateRight: 1,
                                flipHorizontal: 0,
                                flipVertical: 0,
                            },
                        });
                    }else if(treeNum == 2){
                        $('#tree2Img').attr('dataUrl', '/jy/api/getImg?path='+id+'&jyId='+Id);
                        viewer2 = new Viewer(document.getElementById('tree2'), {
                            inline: true,
                            url: 'dataUrl',
                            //navbar: false,
                            zIndexInline: 9999,
                            button: true,
                            backdrop: true,
                            keyboard:true,
                            navbar:false,
                            toolbar: {
                                zoomIn: {
                                    show: 1,
                                    click: function () {
                                        viewer2.destroy();
                                    }
                                },
                                zoomOut: 0,
                                oneToOne: 0,
                                reset: 0,
                                prev: {
                                    click:function(){
                                        viewer2.destroy();
                                        openpre(lxNodes,id,Id,2);
                                    }
                                },
                                next: {
                                    show:1,
                                    click:function(){
                                        viewer2.destroy();
                                        opennext(lxNodes,id,Id,2)
                                    }
                                },
                                rotateLeft: 1,
                                rotateRight: 1,
                                flipHorizontal: 0,
                                flipVertical: 0,
                            },
                        });
                    }
                }else {
                    cxAlertts("已经是最后一张");
                    if(treeNum == 3){
                        $('#tree3Img').attr('dataUrl', '/jy/api/getImg?path='+nextid+'&jyId='+Id);
                        var viewer = new Viewer(document.getElementById('tree3'), {
                            inline: true,
                            url: 'dataUrl',
                            //navbar: false,
                            zIndexInline: 9999,
                            button: true,
                            backdrop: true,
                            keyboard:true,
                            navbar:false,
                            toolbar: {
                                zoomIn: {
                                    show: 1,
                                    click: function () {
                                        viewer.destroy();
                                    }
                                },
                                zoomOut: 0,
                                oneToOne: 0,
                                reset: 0,
                                prev: {
                                    show:1,
                                    click:function(){
                                        viewer.destroy();
                                        openpre(lxNodes,nextid,Id,3);
                                    }

                                },
                                next: {
                                    show:1,
                                    click:function(){
                                        viewer.destroy();
                                        opennext(lxNodes,nextid,Id,3)
                                    }
                                },
                                rotateLeft: 1,
                                rotateRight: 1,
                                flipHorizontal: 0,
                                flipVertical: 0,
                            },
                        });
                    }else if(treeNum == 2){
                        $('#tree2Img').attr('dataUrl', '/jy/api/getImg?path='+nextid+'&jyId='+Id);
                        viewer2 = new Viewer(document.getElementById('tree2'), {
                            inline: true,
                            url: 'dataUrl',
                            //navbar: false,
                            zIndexInline: 9999,
                            button: true,
                            backdrop: true,
                            keyboard:true,
                            navbar:false,
                            toolbar: {
                                zoomIn: {
                                    show: 1,
                                    click: function () {
                                        viewer2.destroy();
                                    }
                                },
                                zoomOut: 0,
                                oneToOne: 0,
                                reset: 0,
                                prev: {
                                    click:function(){
                                        viewer2.destroy();
                                        openpre(lxNodes,nextid,Id,2);
                                    }
                                },
                                next: {
                                    show:1,
                                    click:function(){
                                        viewer2.destroy();
                                        opennext(lxNodes,nextid,Id,2)
                                    }
                                },
                                rotateLeft: 1,
                                rotateRight: 1,
                                flipHorizontal: 0,
                                flipVertical: 0,
                            },
                        });
                    }
                }
            }
        });
    }

    var vue = new Vue({
        el: '#yhgl',
        data: {
            otherUrl:null,
            cl:false,
            da:true,
            allShy:null,
            keyword:null,
            jyxx2:{
                clxxIds:[],
                jyyy:null,
                jysx:5,
                dabh:null,
                jyrLxdh:null,
                jyr:null,
                shrLxdh:null,
                shrId:null,
                shr:null,
                damc:null,
                dalx:null,
            },
        },
        methods: {
            //返回
            goback:function(){
                top.closeCurrentTab();
                top.activeTabByPageId(7777);
                // top.addTabs({
                //     id: "7777",
                //     text: "档案借阅",
                //     icon: "fa fa-tasks",
                //     url: "wdjy?"+this.otherUrl,
                //     targetType: "iframe-tab",
                //     close:true,
                // });
            },
            //全选
            selectAll:function(){
                //var node;
                for(var i = 0;i < index; i++){
                    $('#tree').treeview('checkNode', i);
                }
            },
            //反选
            selectNull:function(){
                //var node;
                for(var i = 0;i < index;i++){
                    $('#tree').treeview('uncheckNode',i);
                }
            },
            cancel:function(){
                $("#userForm").data('bootstrapValidator').resetForm();//清除当前验证的关键之处
                $('#jydaDiv2').modal('hide');
            },
            doSq:function(){
                var bootstrapValidator1 = $("#userForm").data('bootstrapValidator');
                bootstrapValidator1.validate();
                var selected = $('#tree').treeview('getChecked');
                this.jyxx2.clxxIds = [];
                for(var i = 0;i < selected.length;i++){
                    this.jyxx2.clxxIds[i] = selected[i].id;
                }
                if(bootstrapValidator1.isValid()){
                    var myMsg = cxLoad("申请中");
                    this.$http.post('/jy/api/daJy',this.jyxx2).then( function (result) {
                        var data = result.body;
                        if(data.code == 200){
                            layer.close(myMsg);
                            cxAlertOk("成功提交申请，请等待审核员审批")
                            $("#userForm").data('bootstrapValidator').resetForm();//清除当前验证的关键之处
                            $('#jydaDiv2').modal('hide');
                            this.jyxx2.jyyy = null;
                            this.jyxx2.shrId = null;
                            this.jyxx2.jysx = null;
                            setTimeout(function () {
                                top.closeCurrentTab();
                                top.activeTabByPageId(7777);
                            }, 1000);
                        }else{
                            layer.close(myMsg);
                            $("#userForm").data('bootstrapValidator').resetForm();//清除当前验证的关键之处
                            cxAlert(data.mess);
                        }
                    })
                }
            },
            shrChange:function(){
                var shr = this.allShy.findIndex(item => item.id === this.jyxx2.shrId);
            },
        },
        created: function () {
            this.$http.get('/listShUser').then( function (result) {
                var data = result.body;
                if(data.code == 200){
                    this.allShy = data.data;
                }else{
                    cxAlert(data.mess);
                }
            })
        },
        mounted: function () {
            var that = this;
            Object.keys(that.jyxx2).forEach(key => (that.jyxx2[key] = null));
            var url = location.search;
            url = decodeURIComponent(url);
            if(url.indexOf('typeName') !== -1){
                var dabh = url.substring(0,url.indexOf("&"));
                dabh = dabh.substring(dabh.indexOf("=")+1);
                var url2 = url.substring(url.indexOf("&")+1);
                var xmmc = url2.substring(0,url2.indexOf("&"));
                xmmc = xmmc.substring(xmmc.indexOf("=")+1);
                var url3 = url2.substring(url2.indexOf("&")+1);
                var typeName = url3.substring(0,url3.indexOf("&"));
                typeName = typeName.substring(typeName.indexOf("=")+1);
                var url4 = url3.substring(url3.indexOf("&")+1);
                if(url4.indexOf('keyword') != -1){
                    var typeId = url4.substring(0,url4.indexOf("&"));
                    typeId = typeId.substring(typeId.indexOf("=")+1);
                    that.otherUrl = url4.substring(url4.indexOf("&")+1);
                }
                else {
                    var typeId = url4.substring(url4.indexOf("=")+1);
                }

                that.jyxx2.damc = xmmc;
                that.jyxx2.dabh = dabh;
                that.jyxx2.dalx = typeName;
            }else {
                var dabh = url.substring(url.indexOf('dabh=')+5,url.indexOf('&typeId'));
                var typeId = url.substring(url.indexOf('typeId=')+7,url.indexOf('&wdlxName'));
                that.otherUrl = url.substring(url.indexOf('wdlxName'));
                var xmmc = that.otherUrl.substring(that.otherUrl.indexOf('&xmmc=')+6);
                that.jyxx2.dabh = dabh;
                that.jyxx2.damc = xmmc;
                var datas = dabh.split("-");
                var code = datas[0];
                code = datas[0].substring(0,code.length-4);
                this.$http.get('/dagl/api/queryCode?code='+code).then( function (result) {
                    var data = result.body;
                    if (data.code == 200) {
                        that.jyxx2.dalx = data.data.dalxName;
                    }
                });
            }
            $.get('/getUser').then( function (result) {
                var data = result;
                if(data.code == 200){
                    that.jyxx2.jyr = data.data.name;
                    that.jyxx2.jyrLxdh = data.data.phone;
                }
            })
            if(dabh==null){
                cxAlert("请选择要借阅的档案");
                return;
            }
            $.get("/dalr/api/findDaByDabh",{"dabh":dabh,"tyepId":typeId}, function(result){
                if(result.code == 200){
                    for(var i = 0;i < result.data.cl.length;i++){
                        arr.push(result.data.cl[i]);
                        arr2.push(result.data.cl[i].id);
                        that.jyxx2.clxxIds = arr2;
                    }
                    $('#tree').treeview('');
                    $('#tree').treeview({
                        color: "#428bca",
                        highlightSelected:false,     //是否选中高亮显示
                        onhoverColor: "#f5f5f5",    //鼠标滑过的颜色
                        levels: 0 ,                 //设置初始化展开几级菜单 默认为2
                        showBorder:true,                //是否显示边框
                        showCheckbox:false,              //是否显示多选框
                        data:arr,
                        showTags:true,
                        showCheckbox: true,
                        silent:true,
                        //text:arr[0].xmmc,
                        onNodeChecked: nodeChecked,
                        onNodeUnchecked: nodeUnchecked,
                        //checked:true,
                        multiSelect: true,
                        //showTags:true,
                    });
                    for(var i = 0;i < arr.length;i++){
                        $('#tree').treeview('checkNode', i);
                    }
                    index = arr.length;
                }
            });
            $('#userForm').bootstrapValidator({
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    xmmc: {
                        validators: {
                            notEmpty: {
                                message: '档案名称不能为空'
                            }
                        }
                    },
                    jyr: {
                        validators: {
                            notEmpty: {
                                message: '借阅人不能为空'
                            },
                        }
                    },
                    jysx: {
                        validators: {
                            notEmpty: {
                                message: '借阅时限不能为空'
                            },
                        }
                    },
                    shr: {
                        validators: {
                            notEmpty: {
                                message: '审核人不能为空'
                            },
                        }
                    },jyyy: {
                        validators: {
                            notEmpty: {
                                message: '借阅原因不能为空'
                            },
                            stringLength: {
                                max: 100,
                                message: '借阅原因字段长度不能超过100'
                            }
                        }
                    }
                }
            });
        }
    });


</script>

</body>
</html>
